package Demo06.Demo03;

/**
 * 设计一个交易记录类TransRecord (金额字段数据类型定为double)
 * @author sdd
 *
 */

public class Demo06_TransRecord implements Comparable<Demo06_TransRecord>{
    /**客户号*/
    private String customerNumber;

    /**客户姓名*/
    private String customerName;

    /**所属机构号*/
    private String institutionNumber;

    /**性别*/
    private int sex;

    /**账号*/
    private String accountNumber;

    /**发生时间*/
    private String happenTime;

    /**发生额*/
    private double amount;

    public Demo06_TransRecord() {
        super();
    }

    public Demo06_TransRecord(String customerNumber, String customerName, String institutionNumber, int sex, String accountNumber, String happenTime, Double amount) {
        super();
        this.customerNumber = customerNumber;
        this.customerName = customerName;
        this.institutionNumber = institutionNumber;
        this.sex = sex;
        this.accountNumber = accountNumber;
        this.happenTime = happenTime;
        this.amount = amount;
    }

    //get、set方法
    public String getCustomerNumber() {
        return customerNumber;
    }

    public void setCustomerNumber(String customerNumber) {
        this.customerNumber = customerNumber;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getInstitutionNumber() {
        return institutionNumber;
    }

    public void setInstitutionNumber(String institutionNumber) {
        this.institutionNumber = institutionNumber;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public String getAccountNumber() {
        return accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public String getHappenTime() {
        return happenTime;
    }

    public void setHappenTime(String happenTime) {
        this.happenTime = happenTime;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    //重写toStringff
    @Override
    public String toString() {
        return "[" + "客户号  " + customerNumber + "  客户姓名  " + customerName + "  所属机构号  " + institutionNumber + "  性别  "  + sex +"  账号  " + accountNumber + "  发生时间  " + happenTime + "  发生额  " + amount + "]";
    }

    //元素类型实现Comparable接口，重写CompareTo方法
    @Override
    public int compareTo(Demo06_TransRecord o) {
        return (int)(this.getAmount() - o.getAmount());
    }
}

